﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace Kinlo.UI.Main.Converter
{
    public class ResultConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {

            try
            {
                if (value is null)
                {
                    return "";
                }
                var val = 0;
                if (int.TryParse(value.ToString(), out val))
                {
                    if (val == 1)
                        return "合格";
                    else if (val == 2)
                        return "多液";
                    else if (val == 3)
                        return "少液";
                    else if (val == 4)
                        return "后重不在范围";
                    else
                        return "未知";
                } else  if (value.ToString().ToUpper()=="TRUE"|| value.ToString().ToUpper() == "OK")
                {
                    return "OK";
                }else
                {
                    return "NG";
                }
            }
            catch (Exception ex)
            {
                return "";
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
